﻿'use strict';
/**
 * controllers for dynamic table
 * Remove/delete a table row dynamically 
 */

app.controller("EditPostController", EditPostController);
EditPostController.$inject = ['$scope', '$state','$stateParams', 'postService'];
function EditPostController($scope, $state,$stateParams, postService) {
    var id = $stateParams.id;
    var vm = this;
    productService.get({ id: 0 }, function (resp) {
        vm.post = resp.data.list;
    });

    vm.removeRow = function (advertisement) {
        var advertisements = vm.tableParams.data;
        var index = advertisements.indexOf(advertisement);
        advertisementService.delete({ advertisementId: advertisement.id }, function () {
            advertisements.splice(index, 1);
        });
    };
};